home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / LIBRARY / PLOT0.LI < prev    next >
Text File  |  1994-05-11  |  935b  |  34 lines

  1. #       plot(y,x)
  2. #       plots a function of y=y(x)
  3. #       on xy-plane by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
  4. #       e.g. plot(sin(x),x)
  5.  
  6. plot(y_, x_, xmin_, xmax_, ymin_, ymax_, texstep_) := block(numeric:=on,
  7.     graph,
  8.     dx:=(xmax-xmin)/getmaxx,
  9.     dy:=(ymax-ymin)/getmaxy,
  10.     y0:=getmaxy+(ymin)/dy,
  11.     x0:=-xmin/dx,
  12.     xstep:=dx*texstep,
  13.     line(0,y0,getmaxx,y0),
  14.     moveto(0,y0+20),
  15.     writes(xmin),
  16.     moveto(getmaxx-30,y0+20),
  17.     writes(xmax),
  18.     line(x0,0,x0,getmaxy),
  19.     moveto(x0-20,0),
  20.     writes(ymax),
  21.     moveto(x0-20,getmaxy-20),
  22.     writes(ymin),
  23.     setcolor(14),
  24.     moveto(0,getmaxy-(subs(y,x=xmin)-ymin)/dy),
  25.     do( lineto((x-xmin)/dx,getmaxy-(y-ymin)/dy),
  26.     x,xmin,xmax,xstep),
  27.     numeric:=off,
  28.     readchar,
  29.     text,
  30.     local(x0,y0,dx,dy,xstep))
  31. plot(y_, x_, xmin_, xmax_, ymin_, ymax_) := plot(y,x,xmin,xmax,ymin,ymax,10)
  32. plot(y_, x_, xmin_, xmax_) := plot(y,x,xmin,xmax,-5,5,10)
  33. plot(y_, x_) := plot(y,x,-5,5,-5,5,10)
  34.